<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增运营服务商账户')" />
    <th:block th:include="include :: businessCSS" />
    <style type="text/css">
        .layui-input, .layui-textarea{width: 86%;}
        .layui-form {padding: 16px 84px 16px 25px;}
        .layui-form-label{width:180px}
        .layui-form-select dl{margin-left:12%;min-width: 80%;}
        .layui-input-block{margin-left:140px;}
        .layui-edge{margin-right: 7%}
        .hzht{position: relative;}
        .getMore{font-size: 18px;position: absolute;top:3px !important;right: 11vw !important;}
        .getUpload{color: #009688;font-size: 18px;position: absolute;top:3px !important;right: 11vw !important;}
    </style>
</head>
<body>
<form class="layui-form" id="form-data-add" style="padding: 16px 84px 16px 25px;">
	<input type="hidden" id="guid" name="guid"  th:value="${dataInfo?.guid}">
	<input type="hidden" id="partnerId" name="partnerId"  th:value="${dataInfo?.partnerId}">
    <div class="layui-form-item">
        <label class="layui-form-label">运营服务商名称：</label>
        <div class="layui-input-block">
            <input type="text" name="partnerName" id="partnerName" th:value="${dataInfo?.partnerName}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运营公司名称：</label>
        <div class="layui-input-block hzht">
            <input type="text" name="vGsMc" id="vGsMc" th:value="${dataInfo?.vGsMc}" autocomplete="off" placeholder="请输入" readonly class="layui-input buttontext">
            <i class="layui-icon layui-icon-more getMore" th:onclick = "getMore('vGsMc',null,'所属公司',null,false);" style="position: absolute;"></i>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">运营公司简称：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsJc" id="vGsJc" th:value="${dataInfo?.vGsJc}" autocomplete="off" placeholder="请输入" readonly class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运营公司编码：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsBm" id="vGsBm" th:value="${dataInfo?.vGsBm}" autocomplete="off" placeholder="请输入" reaonly class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司税号：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsSh" id="vGsSh" th:value="${dataInfo?.vGsSh}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司电话：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsDh" id="vGsDh" th:value="${dataInfo?.vGsDh}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司传真：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsCz" id="vGsCz" th:value="${dataInfo?.vGsCz}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">公司地址：</label>
        <div class="layui-input-block">
            <input type="text" name="vGsDz" id="vGsDz" th:value="${dataInfo?.vGsDz}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运营服务商开户行：</label>
        <div class="layui-input-block">
            <input type="text" name="vKhh" id="vKhh" th:value="${dataInfo?.vKhh}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">运营服务商银行账号：</label>
        <div class="layui-input-block">
            <input type="text" name="vYhZh" id="vYhZh" th:value="${dataInfo?.vYhZh}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人：</label>
        <div class="layui-input-block">
            <input type="text" name="vLxr" id="vLxr" th:value="${dataInfo?.vLxr}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系方式：</label>
        <div class="layui-input-block">
            <input type="text" name="vLxFs" id="vLxFs" th:value="${dataInfo?.vLxFs}" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">启用状态：</label>
        <div class="layui-input-block">
        	<input type="radio" name="deleted" value="0" title="启用" checked>
	    	<input type="radio" name="deleted" value="1" title="停用" th:checked="${dataInfo?.deleted}">
    	</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">营业执照：</label>
        <div class="layui-input-block yyzz">
            <div class="layui-upload-drag fieldsimg" name="vYyZz" id="vYyZz_upimg">
                <input type="hidden" id="vYyZz" name="vYyZz" th:value="${dataInfo?.vYyZz}"/>
                <div th:class="(${dataInfo?.vYyZz} and ${dataInfo?.vYyZz}!='')?'layui-hide upicon':'upicon'">
                    <i class="layui-icon"></i>
                    <p>点击上传图片</p>
                </div>
                
                <div th:class="(${dataInfo?.vYyZz} and ${dataInfo?.vYyZz}!='')?'' :'layui-hide'" id="uploadDemoView">
                  <img th:src="${dataInfo?.vYyZz}" alt="上传成功后渲染" style="max-width: 196px">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">合作合同：</label>
        <div class="layui-input-block hzht">
        	<input type="text" class="layui-input buttontext" name="vDFilesDefault" id="vDFilesDefault" th:value="${dataInfo?.vDFilesDefault}" readonly/>
            <i class="layui-icon layui-icon-upload getUpload" th:onclick="getUpload('vDFilesDefault','Detail',[[${dataInfo?.guid}]])" getType="vDFilesDefault"></i>
    	</div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">备注：</label>
        <div class="layui-input-block">
        	<textarea id="vBz" name="vBz" class="layui-textarea" placeholder="请输入内容" th:text="${dataInfo?.vBz}"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit="" lay-filter="btn_save" id="btn_save" value="保存">
    </div>
</form>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    /*<![CDATA[*/
    var prefix = ctx + "base/operatorbankinfo",
		fields = [[${fields}]];
		dataInfo = [[${dataInfo}]];
		moduleTable = [[${moduleTable}]];
    var gridColumns = null;
    /*]]>*/
</script>
<script>
var $,layer,form,table;
layui.use(['table','form','layer','jquery','upload'], function () {
    $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,upload = layui.upload;
    $.each(fields,function(i,v){
    	if(v.fieldFrontRequired){//如果字段是必填字段，则加上红*并添加必填验证
    		$("#"+v.fields).parent().prev().html('<font class="f_red">*</font>'+v.fieldName+'：');
    		$("#"+v.fields).attr('lay-verify','required');
    	}
    })


    $(".fieldsimg").each(function(){
		var id=$(this).attr('name')
		upload.render({
			elem: '#'+id+'_upimg',
			url: window.updateurls,
			accept: 'images',
			before: function(obj){
				this.data = {
					'moduleFile':'images'
				}
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result){
				  console.log(index, file, result)
				});
			},
			done: function (res) {
				console.log(res);
				//如果上传失败
				if (res.errno > 0) {
					return layer.msg('上传失败');
				}else{
					if(res.code==500){
						return layer.msg(res.msg);
					}else{
						layer.msg('上传成功');
						var filePath = res.data.filePath;
						$('#'+id).val(filePath)
						layui.$('#'+id+'_upimg').find('.upicon').addClass('layui-hide')
						layui.$('#'+id+'_upimg').find('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', filePath);
					}
				}
			},error: function (err) {
				//演示失败状态，并实现重传
				console.log(err)
			}
		});
	})


  




});
//提交调用的方法
function submitHandler() {
	if($('#partnerId').val()){//通过判断guid是否存在来判断是新增还是保存
		if ($.validate.form()) {
            $.operate.save(prefix + "/editpost", {'infoItems':JSON.stringify([$.common.formToJSON('form-data-add')])});
        }
	}else{
		if ($.validate.form()) {
			$.operate.save(prefix + "/addpost", {'infoItems':JSON.stringify([$.common.formToJSON('form-data-add')])});
		}
	}
}


function getMoreAfter(fieldsList,fields,tindex,fieldName,fieldSearchType,isSearch,isLayer,res){
    console.log("res",res)
    $('#vGsBm').val(res.vGsBm)
    $('#vGsJc').val(res.vGsJc)
    $('#vGsMc').val(res.vGsMc)
    dataInfo.vGsBm = res.vGsBm
    dataInfo.vGsJc = res.vGsJc
    dataInfo.vGsMc = res.vGsMc

}
</script>
</body>
</html>